home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / marionettemadness.swf / scripts / __Packages / com / mosesSupposes / fuse / FuseFMP.as < prev    next >
Text File  |  2007-10-01  |  18KB  |  534 lines

  1. class com.mosesSupposes.fuse.FuseFMP
  2. {
  3.    static var registryKey = "fuseFMP";
  4.    static var VERSION = com.mosesSupposes.fuse.FuseKitCommon.VERSION;
  5.    static var BLUR_ZERO = true;
  6.    function FuseFMP()
  7.    {
  8.    }
  9.    static function simpleSetup()
  10.    {
  11.       com.mosesSupposes.fuse.FuseFMP.initialize(MovieClip.prototype,Button.prototype,TextField.prototype);
  12.       _global.FuseFMP = com.mosesSupposes.fuse.FuseFMP;
  13.       for(var _loc2_ in com.mosesSupposes.fuse.FuseFMP._classes)
  14.       {
  15.          _global[_loc2_] = com.mosesSupposes.fuse.FuseFMP._classes[_loc2_];
  16.       }
  17.    }
  18.    static function initialize(target)
  19.    {
  20.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  21.       {
  22.          com.mosesSupposes.fuse.FuseFMP._shortcuts = {getFilterName:function(f)
  23.          {
  24.             return com.mosesSupposes.fuse.FuseFMP.getFilterName(f);
  25.          },getFilterIndex:function(f)
  26.          {
  27.             return com.mosesSupposes.fuse.FuseFMP.getFilterIndex(this,f);
  28.          },getFilter:function(f, createNew)
  29.          {
  30.             return com.mosesSupposes.fuse.FuseFMP.getFilter(this,f,createNew);
  31.          },writeFilter:function(f, pObj)
  32.          {
  33.             return com.mosesSupposes.fuse.FuseFMP.writeFilter(this,f,pObj);
  34.          },removeFilter:function(f)
  35.          {
  36.             return com.mosesSupposes.fuse.FuseFMP.removeFilter(this,f);
  37.          },getFilterProp:function(prop, createNew)
  38.          {
  39.             return com.mosesSupposes.fuse.FuseFMP.getFilterProp(this,prop,createNew);
  40.          },setFilterProp:function(prop, v)
  41.          {
  42.             com.mosesSupposes.fuse.FuseFMP.setFilterProp(this,prop,v);
  43.          },setFilterProps:function(fOrPObj, pObj)
  44.          {
  45.             com.mosesSupposes.fuse.FuseFMP.setFilterProps(this,fOrPObj,pObj);
  46.          },traceAllFilters:function()
  47.          {
  48.             com.mosesSupposes.fuse.FuseFMP.traceAllFilters();
  49.          }};
  50.          com.mosesSupposes.fuse.FuseFMP._classes = {BevelFilter:flash.filters.BevelFilter,BlurFilter:flash.filters.BlurFilter,ColorMatrixFilter:flash.filters.ColorMatrixFilter,ConvolutionFilter:flash.filters.ConvolutionFilter,DisplacementMapFilter:flash.filters.DisplacementMapFilter,DropShadowFilter:flash.filters.DropShadowFilter,GlowFilter:flash.filters.GlowFilter,GradientBevelFilter:flash.filters.GradientBevelFilter,GradientGlowFilter:flash.filters.GradientGlowFilter};
  51.          com.mosesSupposes.fuse.FuseFMP._getter = {__resolve:function(name)
  52.          {
  53.             var _loc4_ = function()
  54.             {
  55.                var _loc3_ = this;
  56.                if(_loc3_.filters != undefined)
  57.                {
  58.                   var _loc2_ = name.split("_");
  59.                   if(_loc2_[1] == "blur")
  60.                   {
  61.                      _loc2_[1] = "blurX";
  62.                   }
  63.                   return com.mosesSupposes.fuse.FuseFMP.getFilter(this,_loc2_[0] + "Filter",false)[_loc2_[1]];
  64.                }
  65.             };
  66.             return _loc4_;
  67.          }};
  68.          com.mosesSupposes.fuse.FuseFMP._setter = {__resolve:function(name)
  69.          {
  70.             var _loc3_ = function(val)
  71.             {
  72.                var _loc2_ = this;
  73.                if(_loc2_.filters != undefined)
  74.                {
  75.                   com.mosesSupposes.fuse.FuseFMP.setFilterProp(this,name,val);
  76.                }
  77.             };
  78.             return _loc3_;
  79.          }};
  80.       }
  81.       if(arguments[0] == null)
  82.       {
  83.          return undefined;
  84.       }
  85.       var _loc6_ = [MovieClip,Button,TextField];
  86.       for(var _loc13_ in arguments)
  87.       {
  88.          var _loc7_ = false;
  89.          for(var _loc10_ in _loc6_)
  90.          {
  91.             if(arguments[_loc13_] instanceof _loc6_[_loc10_] || arguments[_loc13_] == Function(_loc6_[_loc10_]).prototype)
  92.             {
  93.                _loc7_ = true;
  94.                break;
  95.             }
  96.          }
  97.          if(!_loc7_)
  98.          {
  99.             com.mosesSupposes.fuse.FuseKitCommon.error("201",_loc13_);
  100.          }
  101.          else
  102.          {
  103.             for(var _loc11_ in com.mosesSupposes.fuse.FuseFMP._classes)
  104.             {
  105.                var _loc5_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc11_]();
  106.                for(var _loc8_ in _loc5_)
  107.                {
  108.                   if(typeof _loc5_[_loc8_] != "function")
  109.                   {
  110.                      var _loc4_ = _loc11_.substr(0,-6) + "_" + _loc8_;
  111.                      arguments[_loc13_].addProperty(_loc4_,com.mosesSupposes.fuse.FuseFMP._getter[_loc4_],com.mosesSupposes.fuse.FuseFMP._setter[_loc4_]);
  112.                      _global.ASSetPropFlags(arguments[_loc13_],_loc4_,3,1);
  113.                      if(_loc8_ == "blurX")
  114.                      {
  115.                         _loc4_ = _loc4_.slice(0,-1);
  116.                         arguments[_loc13_].addProperty(_loc4_,com.mosesSupposes.fuse.FuseFMP._getter[_loc4_],com.mosesSupposes.fuse.FuseFMP._setter[_loc4_]);
  117.                         _global.ASSetPropFlags(arguments[_loc13_],_loc4_,3,1);
  118.                      }
  119.                   }
  120.                }
  121.             }
  122.             for(var _loc9_ in com.mosesSupposes.fuse.FuseFMP._shortcuts)
  123.             {
  124.                arguments[_loc13_][_loc9_] = com.mosesSupposes.fuse.FuseFMP._shortcuts[_loc9_];
  125.                _global.ASSetPropFlags(arguments[_loc13_],_loc9_,7,1);
  126.             }
  127.          }
  128.       }
  129.    }
  130.    static function deinitialize()
  131.    {
  132.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  133.       {
  134.          return undefined;
  135.       }
  136.       if(arguments.length == 0)
  137.       {
  138.          arguments.push(MovieClip.prototype,Button.prototype,TextField.prototype);
  139.       }
  140.       for(var _loc8_ in arguments)
  141.       {
  142.          for(var _loc7_ in com.mosesSupposes.fuse.FuseFMP._classes)
  143.          {
  144.             var _loc4_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc7_]();
  145.             for(var _loc5_ in _loc4_)
  146.             {
  147.                if(typeof _loc4_[_loc5_] != "function")
  148.                {
  149.                   var _loc3_ = _loc7_.substr(0,-6) + "_" + _loc5_;
  150.                   _global.ASSetPropFlags(arguments[_loc8_],_loc3_,0,2);
  151.                   arguments[_loc8_].addProperty(_loc3_,null,null);
  152.                   delete arguments[_loc8_][_loc3_];
  153.                }
  154.             }
  155.          }
  156.          for(var _loc6_ in com.mosesSupposes.fuse.FuseFMP._shortcuts)
  157.          {
  158.             _global.ASSetPropFlags(arguments[_loc8_],_loc6_,0,2);
  159.             delete arguments[_loc8_][_loc6_];
  160.          }
  161.       }
  162.    }
  163.    static function getFilterName(instance)
  164.    {
  165.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  166.       {
  167.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  168.       }
  169.       for(var _loc1_ in com.mosesSupposes.fuse.FuseFMP._classes)
  170.       {
  171.          if(instance.__proto__ == Function(com.mosesSupposes.fuse.FuseFMP._classes[_loc1_]).prototype)
  172.          {
  173.             return _loc1_;
  174.          }
  175.       }
  176.       return null;
  177.    }
  178.    static function getFilterIndex(target, filter)
  179.    {
  180.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  181.       {
  182.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  183.       }
  184.       filter = com.mosesSupposes.fuse.FuseFMP.getInstance(filter);
  185.       if(filter === null)
  186.       {
  187.          return -1;
  188.       }
  189.       var _loc2_ = target.filters;
  190.       var _loc1_ = 0;
  191.       while(_loc1_ < _loc2_.length)
  192.       {
  193.          if(_loc2_[_loc1_].__proto__ == filter.__proto__)
  194.          {
  195.             return _loc1_;
  196.          }
  197.          _loc1_ = _loc1_ + 1;
  198.       }
  199.       return -1;
  200.    }
  201.    static function getFilter(target, filter, createNew)
  202.    {
  203.       var _loc1_ = com.mosesSupposes.fuse.FuseFMP.getFilterIndex(target,filter);
  204.       if(_loc1_ == -1)
  205.       {
  206.          if(createNew != true)
  207.          {
  208.             return null;
  209.          }
  210.          _loc1_ = com.mosesSupposes.fuse.FuseFMP.writeFilter(target,filter);
  211.          if(_loc1_ == -1)
  212.          {
  213.             return null;
  214.          }
  215.       }
  216.       return target.filters[_loc1_];
  217.    }
  218.    static function writeFilter(target, filter, propsObj)
  219.    {
  220.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  221.       {
  222.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  223.       }
  224.       filter = com.mosesSupposes.fuse.FuseFMP.getInstance(filter);
  225.       if(filter === null)
  226.       {
  227.          return -1;
  228.       }
  229.       var _loc4_ = target.filters;
  230.       var _loc2_ = com.mosesSupposes.fuse.FuseFMP.getFilterIndex(target,filter);
  231.       if(_loc2_ == -1)
  232.       {
  233.          _loc4_.push(filter);
  234.       }
  235.       else
  236.       {
  237.          _loc4_[_loc2_] = filter;
  238.       }
  239.       target.filters = _loc4_;
  240.       if(typeof propsObj == "object")
  241.       {
  242.          com.mosesSupposes.fuse.FuseFMP.setFilterProps(target,filter,propsObj);
  243.       }
  244.       _loc2_ = com.mosesSupposes.fuse.FuseFMP.getFilterIndex(target,filter);
  245.       return _loc2_;
  246.    }
  247.    static function removeFilter(target, filter)
  248.    {
  249.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  250.       {
  251.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  252.       }
  253.       filter = com.mosesSupposes.fuse.FuseFMP.getInstance(filter);
  254.       var _loc2_ = target.filters;
  255.       var _loc1_ = com.mosesSupposes.fuse.FuseFMP.getFilterIndex(target,filter);
  256.       if(_loc1_ == -1)
  257.       {
  258.          return false;
  259.       }
  260.       _loc2_.splice(_loc1_,1);
  261.       target.filters = _loc2_;
  262.       return true;
  263.    }
  264.    static function getFilterProp(target, propname, createNew)
  265.    {
  266.       var _loc1_ = propname.split("_");
  267.       if(_loc1_[1] == "blur")
  268.       {
  269.          _loc1_[1] = "blurX";
  270.       }
  271.       return com.mosesSupposes.fuse.FuseFMP.getFilter(target,_loc1_[0] + "Filter",createNew)[_loc1_[1]];
  272.    }
  273.    static function setFilterProp(target, propname, value)
  274.    {
  275.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  276.       {
  277.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  278.       }
  279.       var _loc8_ = propname.split("_");
  280.       var _loc5_ = _loc8_[0] + "Filter";
  281.       if(com.mosesSupposes.fuse.FuseFMP._classes[_loc5_] == undefined)
  282.       {
  283.          return undefined;
  284.       }
  285.       var _loc2_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc5_]();
  286.       if(com.mosesSupposes.fuse.FuseFMP.BLUR_ZERO == true && _loc5_ == "BlurFilter")
  287.       {
  288.          _loc2_.blurX = _loc2_.blurY = 0;
  289.       }
  290.       var _loc6_ = _loc8_[1];
  291.       var _loc1_ = target.filters.length || 0;
  292.       while((_loc1_ = _loc1_ - 1) > -1)
  293.       {
  294.          if(target.filters[_loc1_].__proto__ == _loc2_.__proto__)
  295.          {
  296.             _loc2_ = target.filters[_loc1_];
  297.             break;
  298.          }
  299.       }
  300.       if(_loc2_ == null)
  301.       {
  302.          com.mosesSupposes.fuse.FuseKitCommon.error("202",_loc5_,target);
  303.       }
  304.       if(_loc6_ == "blur")
  305.       {
  306.          _loc2_.blurX = value;
  307.          _loc2_.blurY = value;
  308.       }
  309.       else
  310.       {
  311.          if(typeof value == "string" && _loc6_.toLowerCase().indexOf("color") > -1)
  312.          {
  313.             if(value.charAt(0) == "#")
  314.             {
  315.                value = value.slice(1);
  316.             }
  317.             value = value.charAt(1).toLowerCase() == "x" ? Number(value) : Number("0x" + value);
  318.          }
  319.          _loc2_[_loc6_] = value;
  320.       }
  321.       var _loc7_ = target.filters;
  322.       if(_loc1_ == -1)
  323.       {
  324.          _loc7_.push(_loc2_);
  325.       }
  326.       else
  327.       {
  328.          _loc7_[_loc1_] = _loc2_;
  329.       }
  330.       target.filters = _loc7_;
  331.    }
  332.    static function setFilterProps(target, filterOrPropsObj, propsObj)
  333.    {
  334.       if(arguments.length < 2)
  335.       {
  336.          com.mosesSupposes.fuse.FuseKitCommon.error("203",arguments.length);
  337.          return undefined;
  338.       }
  339.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  340.       {
  341.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  342.       }
  343.       var _loc10_ = new Object();
  344.       var _loc11_ = arguments.length == 2;
  345.       if(_loc11_ == false)
  346.       {
  347.          var _loc14_ = com.mosesSupposes.fuse.FuseFMP.getFilterName(com.mosesSupposes.fuse.FuseFMP.getInstance(filterOrPropsObj));
  348.          if(com.mosesSupposes.fuse.FuseFMP._classes[_loc14_] == undefined)
  349.          {
  350.             com.mosesSupposes.fuse.FuseKitCommon.error("204",filterOrPropsObj);
  351.             return undefined;
  352.          }
  353.          _loc10_[_loc14_] = 1;
  354.       }
  355.       else
  356.       {
  357.          propsObj = filterOrPropsObj;
  358.          for(var _loc12_ in propsObj)
  359.          {
  360.             _loc14_ = _loc12_.split("_")[0] + "Filter";
  361.             if(com.mosesSupposes.fuse.FuseFMP._classes[_loc14_] != undefined && _loc10_[_loc14_] == undefined)
  362.             {
  363.                _loc10_[_loc14_] = 1;
  364.             }
  365.          }
  366.       }
  367.       if(!(target instanceof Array))
  368.       {
  369.          target = [target];
  370.       }
  371.       for(var _loc15_ in target)
  372.       {
  373.          var _loc5_ = target[_loc15_];
  374.          for(_loc14_ in _loc10_)
  375.          {
  376.             var _loc3_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc14_]();
  377.             if(com.mosesSupposes.fuse.FuseFMP.BLUR_ZERO == true && _loc14_ == "BlurFilter")
  378.             {
  379.                _loc3_.blurX = _loc3_.blurY = 0;
  380.             }
  381.             var _loc4_ = _loc5_.filters.length || 0;
  382.             while((_loc4_ = _loc4_ - 1) > -1)
  383.             {
  384.                if(_loc5_.filters[_loc4_].__proto__ == _loc3_.__proto__)
  385.                {
  386.                   _loc3_ = _loc5_.filters[_loc4_];
  387.                   break;
  388.                }
  389.             }
  390.             if(_loc3_ == null)
  391.             {
  392.                com.mosesSupposes.fuse.FuseKitCommon.error("202",_loc14_,_loc5_);
  393.             }
  394.             else
  395.             {
  396.                var _loc7_ = String(_loc14_).slice(0,-6) + "_";
  397.                for(_loc12_ in propsObj)
  398.                {
  399.                   var _loc6_ = _loc12_.indexOf(_loc7_) == 0;
  400.                   if(!(_loc11_ == true && _loc6_ == false))
  401.                   {
  402.                      var _loc2_ = propsObj[_loc12_];
  403.                      if(_loc6_ == true)
  404.                      {
  405.                         _loc12_ = _loc12_.slice(_loc7_.length);
  406.                      }
  407.                      if(_loc12_ == "blur")
  408.                      {
  409.                         _loc3_.blurX = _loc2_;
  410.                         _loc3_.blurY = _loc2_;
  411.                      }
  412.                      else
  413.                      {
  414.                         if(typeof _loc2_ == "string" && _loc12_.toLowerCase().indexOf("color") > -1)
  415.                         {
  416.                            if(_loc2_.charAt(0) == "#")
  417.                            {
  418.                               _loc2_ = _loc2_.slice(1);
  419.                            }
  420.                            _loc2_ = _loc2_.charAt(1).toLowerCase() == "x" ? Number(_loc2_) : Number("0x" + _loc2_);
  421.                         }
  422.                         _loc3_[_loc12_] = _loc2_;
  423.                      }
  424.                   }
  425.                }
  426.                var _loc8_ = _loc5_.filters;
  427.                if(_loc4_ == -1)
  428.                {
  429.                   _loc8_.push(_loc3_);
  430.                }
  431.                else
  432.                {
  433.                   _loc8_[_loc4_] = _loc3_;
  434.                }
  435.                _loc5_.filters = _loc8_;
  436.             }
  437.          }
  438.       }
  439.    }
  440.    static function getAllShortcuts()
  441.    {
  442.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  443.       {
  444.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  445.       }
  446.       var _loc2_ = [];
  447.       for(var _loc4_ in com.mosesSupposes.fuse.FuseFMP._classes)
  448.       {
  449.          var _loc1_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc4_]();
  450.          for(var _loc3_ in _loc1_)
  451.          {
  452.             if(typeof _loc1_[_loc3_] != "function")
  453.             {
  454.                _loc2_.push(_loc4_.substr(0,-6) + "_" + _loc3_);
  455.                if(_loc3_ == "blurX")
  456.                {
  457.                   _loc2_.push(_loc4_.substr(0,-6) + "_blur");
  458.                }
  459.             }
  460.          }
  461.       }
  462.       return _loc2_;
  463.    }
  464.    static function traceAllFilters()
  465.    {
  466.       if(com.mosesSupposes.fuse.FuseFMP._classes == undefined)
  467.       {
  468.          com.mosesSupposes.fuse.FuseFMP.initialize(null);
  469.       }
  470.       var _loc1_ = "------ FuseFMP filter properties ------\n";
  471.       for(var _loc4_ in com.mosesSupposes.fuse.FuseFMP._classes)
  472.       {
  473.          _loc1_ += _loc4_;
  474.          var _loc2_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc4_]();
  475.          for(var _loc3_ in _loc2_)
  476.          {
  477.             if(typeof _loc2_[_loc3_] != "function")
  478.             {
  479.                _loc1_ += "\t- " + _loc4_.substr(0,-6) + "_" + _loc3_;
  480.                if(_loc3_ == "blurX")
  481.                {
  482.                   _loc1_ += "\t- " + _loc4_.substr(0,-6) + "_blur";
  483.                }
  484.             }
  485.          }
  486.          _loc1_ += "\n";
  487.       }
  488.       com.mosesSupposes.fuse.FuseKitCommon.output(_loc1_);
  489.    }
  490.    static function getInstance(filter)
  491.    {
  492.       if(filter instanceof flash.filters.BitmapFilter)
  493.       {
  494.          return flash.filters.BitmapFilter(filter);
  495.       }
  496.       if(typeof filter == "function")
  497.       {
  498.          for(var _loc4_ in com.mosesSupposes.fuse.FuseFMP._classes)
  499.          {
  500.             if(filter == com.mosesSupposes.fuse.FuseFMP._classes[_loc4_])
  501.             {
  502.                var _loc1_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc4_]();
  503.                if(com.mosesSupposes.fuse.FuseFMP.BLUR_ZERO == true && _loc4_ == "BlurFilter")
  504.                {
  505.                   _loc1_.blurX = _loc1_.blurY = 0;
  506.                }
  507.                return _loc1_;
  508.             }
  509.          }
  510.       }
  511.       if(typeof filter == "string")
  512.       {
  513.          var _loc3_ = String(filter);
  514.          if(_loc3_.substr(-6) != "Filter")
  515.          {
  516.             _loc3_ += "Filter";
  517.          }
  518.          for(_loc4_ in com.mosesSupposes.fuse.FuseFMP._classes)
  519.          {
  520.             if(_loc4_ == _loc3_)
  521.             {
  522.                _loc1_ = new com.mosesSupposes.fuse.FuseFMP._classes[_loc4_]();
  523.                if(com.mosesSupposes.fuse.FuseFMP.BLUR_ZERO == true && _loc4_ == "BlurFilter")
  524.                {
  525.                   _loc1_.blurX = _loc1_.blurY = 0;
  526.                }
  527.                return _loc1_;
  528.             }
  529.          }
  530.       }
  531.       return null;
  532.    }
  533. }
  534.